package com.six.work.mapper;

import com.six.work.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResponsesMapper {
    @Select("SELECT responses.*,applicant.applicant_name FROM responses responses JOIN applicant applicant on responses.applicant_id = applicant.applicant_id ORDER BY applicant.applicant_id DESC")
    List<ResView> findAllResponses();


    @Delete("DELETE from responses where response_id=#{response_id}")  //删除
    Integer DelResByID(Integer response_id);

    @Select("SELECT * from responses where response_id=#{response_id}")
    Responses SelectResByID(Integer response_id);

    @Select("SELECT * ,applicant.applicant_name FROM responses responses JOIN applicant applicant on responses.applicant_id = applicant.applicant_id and post_id=#{post_id}")
    List<ResView> SelectResByPosID(Integer post_id);


    @Update("UPDATE responses SET `state` = '已驳回' \n" +
            "WHERE (response_id = #{response_id})")
    String updateResState(Integer response_id);

    @Update("UPDATE responses SET `state` = '已通过' \n" +
            "WHERE (response_id = #{response_id})")
    String updateResState1(Integer response_id);

    @Insert("insert into responses (response_id,post_id,response_text,applicant_id) values(#{response_id},#{post_id},#{response_text},#{applicant_id})")
    Integer insertRes(Responses responses);   //增加

}
